package com.shop2cn.iapi.agentproducts.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.CategoryDto;
import com.shop2cn.iapi.agentproducts.parameter.SecondCategoryListBean;
import com.shop2cn.iapi.agentproducts.service.SecondCategoryListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.AgentUsers;

/**
*所有商品已使用的二级类目列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SecondCategoryList{
	private static SecondCategoryListBean secondcategorylistBean;
	private static SecondCategoryListCall secondcategorylistCall;

	//渠道商
	private static int sellerId = AgentUsers.rootUserId;
	private static String sellerName = "NickautoTest";
	//渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	//渠道商->代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";

	//vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("所有商品已使用的二级类目列表");
	}

	@Before
	public void caseUp() {
		secondcategorylistBean=new SecondCategoryListBean();
		secondcategorylistCall=new SecondCategoryListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(secondcategorylistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SecondCategoryList_01() {
		Logger.start(true,"渠道商所有商品已使用的二级类目列表");
		try {
			secondcategorylistBean.setUserId(AgentUsers.rootUserId);
			secondcategorylistCall.setData(secondcategorylistBean);
			secondcategorylistCall.callService();			
			Logger.verifyEquals("200",secondcategorylistCall.getString("code"),"验证code");
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<CategoryDto> categoryDtoList = ymtProductsIWapper.getSecondCategoryByUserId(vipRootUserId);
			List<CategoryDto> categoryDtos = secondcategorylistCall.getProductList();
			Logger.verifyEquals(true,categoryDtoList.size() == categoryDtos.size()+1,"验证类目类表");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SecondCategoryList_02() {
		Logger.start(true,"代理商所有商品已使用的二级类目列表");
		try {
			secondcategorylistBean.setUserId(agentUserId1);
			secondcategorylistCall.setData(secondcategorylistBean);
			secondcategorylistCall.callService();
			Logger.verifyEquals("200",secondcategorylistCall.getString("code"),"验证code");
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<CategoryDto> categoryDtoList = ymtProductsIWapper.getSecondCategoryByUserId(agentUserId1);
			List<CategoryDto> categoryDtos = secondcategorylistCall.getProductList();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}